package com.sakura.protorype.improve;

import com.sakura.protorype.Sheep;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.ToString;

/**
 * @Author Sakura
 * @Date 2022/11/21 16:55
 * @Version 1.0
 */
@Data
@ToString
@NoArgsConstructor
@AllArgsConstructor
public class Sheep2 implements Cloneable {
    private String name;
    private int age;
    private String color;
    private String address = "蒙古羊";
    public Sheep2 friend; //是对象, 克隆是会如何处理

    public Sheep2(String name, int age, String color) {
        super();
        this.name = name;
        this.age = age;
        this.color = color;
    }

    //TODO 克隆该实例，使用默认的clone方法来完成
    @Override
    protected Object clone()  {

        Sheep2 sheep = null;
        try {
            sheep = (Sheep2)super.clone();
        } catch (Exception e) {
            // TODO: handle exception
            System.out.println(e.getMessage());
        }
        // TODO Auto-generated method stub
        return sheep;
    }
}
